package com.hycc.base;

public class RecursiveAdd {

    public long getByIndex(int index){
        long sum = 0;

        if(index<0){
            return 0;
        }

        if(index<=1&& index>=0){
            sum=index;
        }else{
            sum = getByIndex(index-1)+getByIndex(index-2);
        }

        return sum;
    }
}

class RecursiveAddDemo {
    public static void main(String[] args) {
        for (int i = 1; i <= 30; i++) {
            System.out.println("第"+i+"\t"+new RecursiveAdd().getByIndex(i));
        }
    }
}

